package com.cloud.easy.im.handler.qos;

/**
 * 通过单利方式实现c2s的qos机制
 *
 * @author wangjian
 * @version 0.1.0
 * @create 2020年10月10日4:29 下午
 */
public class QoS4RecivedDaemonC2S extends QoS4RecivedDaemonRoot {

    private static Builder builder = new Builder();

    protected QoS4RecivedDaemonC2S(Builder builder) {
        super(builder.chechInterval, builder.messagesValidTime, builder.tag);
    }

    /**
     * 单利对象
     */
    private static class SingletonHolder {
        private static final QoS4RecivedDaemonC2S INSTANCE = new QoS4RecivedDaemonC2S(builder);
    }

    public static QoS4RecivedDaemonC2S getInstance() {
        return QoS4RecivedDaemonC2S.SingletonHolder.INSTANCE;
    }

    /**
     * 单利对象构建参数
     */
    static class Builder {
        private int chechInterval = 0;
        private int messagesValidTime = 0;
        private String tag = "-本机qos";

        public Builder() {
        }

        public Builder(int chechInterval, int messagesValidTime, boolean debug, String tag) {
            this.chechInterval = chechInterval;
            this.messagesValidTime = messagesValidTime;
            this.tag = tag;
        }
    }

    public static QoS4RecivedDaemonC2S setBuilder(int chechInterval, int messagesValidTime
            , boolean debug, String tag){
        builder = new Builder(chechInterval, messagesValidTime, debug, tag);
        return getInstance();
    }
}
